<?php
    // estilos -- ver por qué no puedo usar class con un css - otra clase debe estar bloqueandolo
    $tabla_orga_td = 'vertical-align: middle; background-color: transparent; border: 1px;';    

    // imagenes
    $prev_img = $this->Html->image("restaurante/ic_navegar_left.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left"));    
    $next_img = $this->Html->image("restaurante/ic_navegar.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right"));    
    $prev_img_disabled = $this->Html->image("restaurante/ic_nav_left_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left_disabled"));    
    $next_img_disabled = $this->Html->image("restaurante/ic_navegar_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right_disabled"));    


    $volver_img = $this->Html->image("restaurante/ic_back.png", array("id" => "back_icon"));    
    $nuevo_img = $this->Html->image("restaurante/ic_add.png", array("id" => "add_icon"));    
    $cancel_img = $this->Html->image("restaurante/ic_cancel.png", array("id" => "back_icon"));    
    $save_img = $this->Html->image("restaurante/ic_ok.png", array("id" => "save_icon"));    
    
    $editar_img = $this->Html->image("restaurante/doc_images.png", array("width" => "24px", "height" => "24px"));    
    $qr_img = $this->Html->image("restaurante/qr_icon.bmp", array("width" => "24px", "height" => "24px"));    
    
?>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  
<script type="text/javascript">
$(document).ready(function() {
        $('.datepicker').datepicker({
        format: "dd-mm-yyyy",
        todayBtn: "linked",
        orientation: "bottom right",
        autoclose: true,
        todayHighlight: true
    });
});
</script>

<!--- MARCO DE LA PANTALLA ------>
<table><tr><td style="padding: 20px; background: white; border: none;">

<table>
    <tr style="border: 2px;">
        <td style="width: 15%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->image("restaurante/ic_resto.png", array("width" => "64px", "height" => "64px", "id" => "resto_icon"));?></td>
        <td style="width: 55%; text-align:left; <?php echo $tabla_orga_td;?>"><h1 class="titulo_ventana">Descuentos</h1></td>
        <td style="width: 30%; text-align:right; <?php echo $tabla_orga_td;?>">
            <table>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Usuario: '.$nombre_usuario;?></td></tr>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link('Cerrar sesión', array("controller"=>"users", "action"=>"logout"), array('title' => 'Cerrar sesión', 'escape' => false));?></td></tr>
            </table>
        </td>
    </tr>      
</table>
<hr>

<!--- CONTROLES Y BOTONERA FILTROS ------>

<?php echo $this->Form->create('Descuento', array('action'=>'/index','novalidate' => true)); ?>
<table>
    <tr>
        <td style="width: 10%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_codigo', array('label' => 'Código')); ?></td>
        <td style="width: 30%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_titulo', array('label' => 'Título')); ?></td>
    
        <td style="width:20%; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_desde', array( 'label' => 'Desde', 'class' => 'form-control datepicker','type' => 'text'));?>     
        <td style="width:20%; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_hasta', array( 'label' => 'Hasta', 'class' => 'form-control datepicker','type' => 'text'));?>  
     
            
        <td style="width: 15%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_activo', array('checked' => true,'label' => 'Activos')); ?></td>
        <td style="width: 2%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Buscar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->submit('restaurante/ic_search.png',array('class' => 'boton-buscar')); ?> </td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Limpiar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->button('', array('type'=>'reset','class' => 'boton-limpiar')); ?></td>   
    </tr>
</table>
<?php echo $this->Form->end(); ?>

<!--- GRILLA ------>
<table>
    <tr>
        <th style="width: 10%;"><?php echo $this->Paginator->sort('Descuento.codigo','Código',array('direction' => 'asc') ); ?></th>
        <th style="width: 20%;"><?php echo $this->Paginator->sort('Descuento.titulo','Título',array('titulo' => 'asc') ); ?></th>
    
        <th style="width: 25%;"><?php echo $this->Paginator->sort('Descuento.descripcion','Descripción',array('direction' => 'asc') ); ?></th>
        <th style="width: 10%;"><?php echo $this->Paginator->sort('Descuento.porcentaje','Porcentaje [%]',array('direction' => 'asc') ); ?></th>
        <th style="width: 10%;text-align:center;"><?php echo $this->Paginator->sort('Descuento.fecha_desde','Desde',array('fecha_desde' => 'asc') ); ?></th>
        <th style="width: 10%;text-align:center;"><?php echo $this->Paginator->sort('Descuento.fecha_hasta','Hasta',array('fecha_hasta' => 'asc') ); ?></th>

        
        <th style="width: 5%; text-align:center;"><?php echo "Activo"; ?></th>
        <th style="width: 5%; text-align:center;"><?php echo "Editar"; ?></th>
        <th style="width: 5%; text-align:center;"><?php echo "QR"; ?></th>
    </tr>
    <?php foreach ($descuentos as $descuento): ?>
    <tr>
        <td style="width: 10%;"><?php echo $descuento['Descuento']['codigo']; ?> </td>
        <td style="width: 20%;"><?php echo $descuento['Descuento']['titulo']; ?> </td>
       
        <td style="width: 25%;"><?php echo $descuento['Descuento']['descripcion']; ?> </td>
        <td style="width: 10%;text-align:center;"><?php echo $descuento['Descuento']['porcentaje']; ?> </td>
        <td style="width: 10%;text-align:center;"><?php echo $descuento['Descuento']['fecha_desde']; ?> </td>
        <td style="width: 10%;text-align:center;"><?php echo $descuento['Descuento']['fecha_hasta']; ?> </td>
        
        <td style="width: 5%; text-align:center;"><?php echo ($descuento['Descuento']['activo']==1? 'X' : ''); ?> </td>
        <td style="width: 5%; text-align:center;"><?php echo $this->Html->link($editar_img, '/descuentos/editar/'.$descuento['Descuento']['id'], array('escape' => false)); ?> </td>
        <td style="width: 5%; text-align:center;"><?php echo $this->Html->link($qr_img, '/descuentos/qr/'.$descuento['Descuento']['id'], array('escape' => false)); ?> </td>
        
    </tr>    
    <?php endforeach; ?>    
</table>

<!--- PAGINADO ------>
<table>
    <tr>
        <td style="width: 10%; <?php echo $tabla_orga_td;?>"><?php  echo $this->Paginator->prev(!$this->Paginator->hasPrev() ? null : $prev_img, array('escape' => false), !$this->Paginator->hasPrev() ? $prev_img_disabled : null, array('class'=>'prev disabled','escape' => false));?></td>
        <td style="width: 10%; <?php echo $tabla_orga_td;?>"><?php  echo $this->Paginator->next(!$this->Paginator->hasNext() ? null : $next_img, array('escape' => false), !$this->Paginator->hasNext() ? $next_img_disabled : null, array('class'=>'next disabled','escape' => false));?></td>
        <td style="width: 80%; <?php echo $tabla_orga_td;?>"></td>
    </tr>
</table>

<!--- BOTONERA ------->
<table>
    <tr>
        <td style="width: 10%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Volver'; ?></td>
        <td style="width: 10%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link($volver_img, array("controller"=>"mainmenus", "action"=>"index"), array('class' => 'button', 'title' => 'Volver', 'escape' => false));?></td>
        <td style="width: 60%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width: 10%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Nuevo'; ?></td>
        <td style="width: 10%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link($nuevo_img, array("controller"=>"descuentos", "action"=>"nuevo"), array('class' => 'button', 'title' => 'Nuevo', 'escape' => false));?></td>
    </tr>
</table>

<!-- overlayed element -->
<div id="dialogModal">
     <!-- the external content is loaded inside this tag -->
     <div class="contentWrap"></div>
</div>

<!--- FIN MARCO DE LA PANTALLA ------>
</td></tr></table>
